home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / etc / network / if-up.d / ethtool < prev    next >
Text File  |  2009-04-28  |  1KB  |  47 lines

  1. #!/bin/sh
  2.  
  3. ETHTOOL=/usr/sbin/ethtool
  4.  
  5. test -x $ETHTOOL || exit 0
  6.  
  7. # Find settings with a given prefix and print them as they appeared in
  8. # /etc/network/interfaces, only with the prefix removed.
  9. gather_settings () {
  10.     env | awk -F= "/^IF_$1/ {
  11.                        sub(\"^IF_$1\", \"\");
  12.                        gsub(\"_\", \"-\");
  13.                        print tolower(\$1), \$2
  14.                    }"
  15. }
  16.  
  17. # Gather together the mixed bag of settings applied with -s/--change
  18. SETTINGS="\
  19. ${IF_LINK_SPEED:+ speed $IF_LINK_SPEED}\
  20. ${IF_LINK_DUPLEX:+ duplex $IF_LINK_DUPLEX}\
  21. "
  22.  
  23. # WOL has an optional pass-key
  24. set -- $IF_ETHERNET_WOL
  25. SETTINGS="$SETTINGS${1:+ wol $1}${2:+ sopass $2}"
  26.  
  27. # Autonegotiation can be on|off or an advertising mask
  28. case "$IF_ETHERNET_AUTONEG" in
  29. '')    ;;
  30. on|off)    SETTINGS="$SETTINGS autoneg $IF_ETHERNET_AUTONEG" ;;
  31. *)    SETTINGS="$SETTINGS autoneg on $IF_ETHERNET_AUTONEG" ;;
  32. esac
  33.  
  34. [ -z "$SETTINGS" ] || $ETHTOOL --change "$IFACE" $SETTINGS
  35.  
  36. SETTINGS="$(gather_settings ETHERNET_PAUSE_)"
  37. [ -z "$SETTINGS" ] || $ETHTOOL --pause "$IFACE" $SETTINGS
  38.  
  39. SETTINGS="$(gather_settings HARDWARE_IRQ_COALESCE_)"
  40. [ -z "$SETTINGS" ] || $ETHTOOL --coalesce "$IFACE" $SETTINGS
  41.  
  42. SETTINGS="$(gather_settings HARDWARE_DMA_RING_)"
  43. [ -z "$SETTINGS" ] || $ETHTOOL --ring "$IFACE" $SETTINGS
  44.  
  45. SETTINGS="$(gather_settings OFFLOAD_)"
  46. [ -z "$SETTINGS" ] || $ETHTOOL --offload "$IFACE" $SETTINGS
  47.